package com.yjhb.android.sbz.activity;

import android.content.Intent;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;

import com.yjhb.android.sbz.R;
import com.yjhb.android.sbz.entity.UserInfo;
import com.yjhb.android.sbz.mvp.login.MsgLoginPresenter;
import com.yjhb.android.sbz.mvp.login.MsgLoginView;

import com.jojo.android.zxlib.tool.ZxDataTool;
import com.jojo.android.zxlib.tool.ZxToast;

import butterknife.BindView;

/**
 * 创建者 zx
 * 创建时间 2020/11/18 10:59
 */
public class PhoneLoginActivity extends BaseActivity<MsgLoginPresenter> implements MsgLoginView {
    private final String TAG = "PhoneLoginActivity";

    @BindView(R.id.et_tel)
    EditText et_tel;

    @Override
    protected MsgLoginPresenter initPresenter() {
        return new MsgLoginPresenter(this);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_login_phone;
    }

    @Override
    protected void initUI() {
        setStatusBarLightMode(true);
    }

    @Override
    protected void initData() {

    }

    @Override
    protected void regEvent() {

    }

    public void onLogin(View view) {
        if (TextUtils.isEmpty(et_tel.getText())) {
            ZxToast.showCenterToastLight("请输入手机号");
            return;
        }
        String tel = et_tel.getText().toString();
        if (!ZxDataTool.isMobile(tel)) {
            ZxToast.showCenterToastLight("请输入正确的手机号");
            return;
        }
        Intent intent = new Intent(this, VerificationCodeActivity.class);
        intent.putExtra("tel", tel);
        startActivity(intent);
    }


    @Override
    public void onMsgSend() {

    }

    @Override
    public void onLoginSuccess(UserInfo userInfo) {
//        App.updateUserInfo(userInfo);
    }

    @Override
    public void loggingIn() {

    }

    @Override
    public void onFailure(int code, String msg) {
//        ZxToast.showCenterToastLight(msg);
    }
}
